package com.suli.account.service.serviceImpl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.suli.account.entity.RealTimeAnnounce;
import com.suli.account.mapper.RealTimeAnnounceMapper;
import com.suli.account.service.RealTimeAnnounceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author SuLi
 * @since 2022-04-17
 */
@Service
public class RealTimeAnnounceServiceImpl extends ServiceImpl<RealTimeAnnounceMapper, RealTimeAnnounce> implements RealTimeAnnounceService {

    @Autowired
    RealTimeAnnounceMapper announceMapper;

    @Override
    public Map<String, Object> getRealAnnounce(Long page, Long limit) {
        Page<RealTimeAnnounce> page1=new Page<>(page,limit);
        Page<RealTimeAnnounce> realTimeAnnouncePage = announceMapper.selectPage(page1, null);
        long total = realTimeAnnouncePage.getTotal();
        List<RealTimeAnnounce> records = realTimeAnnouncePage.getRecords();
        Map<String, Object> map=new HashMap<>();
        map.put("total", total);
        map.put("realList", records);
        return map;
    }
}
